var DataType = {
    parse: function(v) {
        if (v == null) {
            return 0;
        }
        v = parseInt(v);
        if (isFinite(v)) {
            return v;
        } else {
            gg.error('datatype error');
        }
    },
    '+': function(a, b) {
        b = this.parse(b);
        return a + b;
    },
    '-': function(a, b) {
        b = this.parse(b);
        return a - b;
    },
    '*': function(a, b) {
        b = this.parse(b);
        return a * b;
    },
    '/': function(a, b) {
        b = this.parse(b);
        return parseInt(a / b);
    },
    max: function(a, b) {
        b = this.parse(b);
        return Math.max(a, b);
    },
    min: function(a, b) {
        b = this.parse(b);
        return Math.min(a, b);
    },
    clamp: function(a, b, options) {
        var min = options.min || 0;
        var max = options.max || 0;
        return b < min ? min : b < max ? b : max;
    }
};

module.exports = DataType;